<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>我的jsp项目</title>
    <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
    <style type="text/css">
    	span{
    		color:red;
    	}
    </style>
  </head>
  
  <body>
  	<h3>系统登录</h3>
 	${fn:escapeXml("<script>") }
  	<%
  		String code = request.getParameter("code");
  		if("10001".equals(code)) {	
  		
  	%>
  		<div style="color:red">用户名或密码错误</div>
  	<%} else if("10002".equals(code)) { %>
  		<div style="color:red">请先登录</div>
  	<%} %>
  	
  	<form action="login.jspx" method="post" id="myform">
  		UserName: <input type="text" name="username"/><span id="name_error"></span> <br/>
  		Password: <input type="password" name="password"/><span id="pwd_error"></span> <br/>
  		验证码:<input type="text" name="yanzhengma">
  		<img alt="yanzhengma" src="jcaptcha.jpg" id="yanzheng"><a href="javascript:;" id="yan">看不清请点击这里</a><br/>
  		<input type="button" value="Login" id="btn"/>
  	</form>
  	<script type="text/javascript">
  		$(document).ready(function(){
  			$("#yan").click(function(){
  				$("#yanzheng").attr("src","jcaptcha.jpg?t="+new Date());
  			});
  		
  			$("#btn").click(function(){
  				var name = $("input[name='username']").val();
  				var pwd = $("input[name='password']").val();
  				if(name.trim() == "") {
  					$("#name_error").html("请输入用户名");
  					return;
  				}
  				if(pwd == "") {
  					$("#pwd_error").html("请输入密码");
  					return;
  				}
  				$("#myform").submit();
  				
  			});
  			
  		});
  	
  	</script>
  </body>
</html>
